((e, func) => {
    "use strict";
    console.log(e);
    console.log(func);
    console.log('e.threeUtils=', e.threeUtils = {});
    func(e.threeUtils)
})(this, function (threeUtils) {
    "use strict";

    // 获取视觉宽度
    function getRotatedVisualWidth(perspective, originHeight, originWidth, rotateDeg, direction = true) {
        const zIndex = getZIndex(originHeight, rotateDeg, direction)
        return getPerspectiveFactor(+perspective, zIndex) * originWidth
    }

    // 获取视觉高度
    function getRotateVisualHeight(perspective, originHeight, rotateDeg) {
        const zIndex = -(originHeight * Math.sin((rotateDeg * Math.PI) / 180)) / 2
        return getPerspectiveFactor(+perspective, zIndex) * (originHeight * Math.cos((rotateDeg * Math.PI) / 180))
    }

    function getRotateHeight(originHeight, rotateDeg) {
        return originHeight * Math.cos((rotateDeg * Math.PI) / 180)
    }

    // 获取突出点在Z轴方向上的距离
    function getZIndex(originHeight, rotateDeg, direction) {
        return (((direction && '-') + Number(originHeight)) / 2) * Math.sin((rotateDeg * Math.PI) / 180)
    }


    // 获取透视因子 = p / (p - D)
    function getPerspectiveFactor(perspective, zIndex) {
        return perspective / (perspective - zIndex)
    }


    // 解析矩阵获取角度
    function getRotateDeg(transform) {
        const values = transform.split('(')[1].split(')')[0].split(',').map(parseFloat);

        // Extract rotation angles from the matrix
        const m11 = values[0], m12 = values[1], m13 = values[2];
        const m21 = values[4], m22 = values[5], m23 = values[6];
        const m31 = values[8], m32 = values[9], m33 = values[10];

        const rotationX = Math.atan2(m32, m33) * (180 / Math.PI);
        const rotationY = Math.atan2(-m31, Math.sqrt(m32 * m32 + m33 * m33)) * (180 / Math.PI);
        const rotationZ = Math.atan2(m21, m11) * (180 / Math.PI);

        return {
            x: Math.abs(rotationX),
            y: rotationY,
            z: rotationZ
        };
    }

    Object.assign(threeUtils, {
        getRotatedVisualWidth,
        getZIndex,
        getPerspectiveFactor,
        getRotateDeg,
        getRotateVisualHeight,
        getRotateHeight
    })
    return threeUtils
})